package com.example.picker.slice;

import com.example.picker.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Picker;

import java.util.ArrayList;
import java.util.List;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        Picker picker1 = (Picker)findComponentById(ResourceTable.Id_picker1);
        picker1.setDisplayedData(new String[]{"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"});

        Picker picker2 = (Picker)findComponentById(ResourceTable.Id_picker2);
        List<String> shiList =new ArrayList<String>();
        for(int i=1;i<=12;i++){
            shiList.add(i+"时");
        }
        String [] shi = shiList.toArray( new String[]{});

        picker2.setMaxValue(12);
        picker2.setDisplayedData(shi);

        Picker picker3 = (Picker)findComponentById(ResourceTable.Id_picker3);

        List<String> fenList =new ArrayList<String>();
        for(int i=0;i<=59;i++){
            fenList.add(i+"分");
        }
        String [] fen = fenList.toArray( new String[]{});
        picker3.setMaxValue(60);
        picker3.setDisplayedData(fen);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
